import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Solution {


    public static void main(String[] args) {
        int[] arr={-1,-1,2,0,-4,1};
        threeSum(arr);


    }
    public static List<List<Integer>> threeSum(int[] nums) {
        int size = nums.length;
        Arrays.sort(nums);



        List<List<Integer>> List = new ArrayList<>();


        for (int i = 0; i < size; i++) {

            if (i != 0 && nums[i] == nums[i - 1]) {
                continue;
            }
            int tmp = nums[i];
            int size1 = size-1;
            for (int j = i + 1; j < size1; j++) {

                int total = nums[j] + nums[size1];
                if (total == -tmp) {

                    List<Integer> list = new ArrayList<>();
                    list.add(nums[i]);
                    list.add(nums[j]);
                    list.add(nums[size1]);

                    List.add(list);
                    System.out.print(i);

                } else if (total > -tmp) {
                    size1--;
                }
            }
        }
        return List;

    }

}








